package cn.dankal.flyaudio.presenter;

import androidx.annotation.NonNull;
import api.ShopUserServiceFactory;
import cn.dankal.basiclib.pojo.BaseResponse;
import cn.dankal.basiclib.pojo.CardDetailEntity;
import cn.dankal.basiclib.rx.AbstractSubscriber;
import cn.dankal.flyaudio.contract.CardDetailsContract;

/**
 * <pre>
 *     e-mail : junfeng.nie@duntech.com.cn
 *     time   : 27/7/2020
 *     desc   :
 *     version: cn.dankal.flyaudio.presenter
 *     Copyright: Copyright（c）2018
 *     Company:
 * </pre>
 *
 * @author niejunfeng
 */
public class CardDetailPresenter implements CardDetailsContract.Presenter {
    private CardDetailsContract.View mView;

    @Override
    public void getDetails(String uuid) {
        mView.showLoadingDialog();
        ShopUserServiceFactory.getCardDetails(uuid)
                .subscribe(new AbstractSubscriber<BaseResponse<CardDetailEntity>>(mView) {
                    @Override
                    public void onNext(BaseResponse<CardDetailEntity> cardDetailEntityBaseResponse) {
                        mView.dismissLoadingDialog();
                        mView.onSuccess(cardDetailEntityBaseResponse.getData());
                    }
                });
    }

    @Override
    public void attachView(@NonNull CardDetailsContract.View view) {
        this.mView = view;
    }

    @Override
    public void detachView() {
        this.mView = null;
    }
}
